from Page.Page import Page
from Page.Page1 import Page1
from Page.Page2 import Page2
from selenium import webdriver
import time,pytest,logging,os
from datetime import datetime

@pytest.fixture(scope='function')
def driver():
    driver=webdriver.Edge()
    driver.maximize_window()
    yield driver
    driver.implicitly_wait(5)
    driver.quit()
# 测试用例
def test_a3mall_01_login_and_search(driver):
    logging.info("用例1：登录搜索并下单支付")
    try:
        po=Page(driver)
        po.luoji_a3mall_01_login_and_search()
    except Exception as e:
        datime=datetime.now().strftime('%Y%m%d-%H%M%S')
        driver.save_screenshot(f'{datime}.png')

        print(e)

def test_a3mall_02_search_and_gwc(driver):
    logging.info("用例2：搜索加入购物车并下单支付")
    try:
        po=Page1(driver)
        po.luoji_a3mall_02_gwc_and_search()
    except Exception as e:
        datime1 = datetime.now().strftime('%Y%m%d-%H%M%S')
        driver.save_screenshot(f'{datime1}.png')
        print(e)

def test_a3mall_03_login_search(driver):
    logging.info("用例3：登录并搜索商品")
    try:
        po=Page2(driver)
        po.luoji_a3mall_03_login_search()
    except Exception as e:
        datime2 = datetime.now().strftime('%Y%m%d-%H%M%S')
        driver.save_screenshot(f'{datime2}.png')
        print(e)

